home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2010 Summer - Disc 1 / WN_Ete2010_CD1.iso / Onglet5 / Weezo / Weezo setup.exe / {code_appDir} / www / local / uiUsers.php < prev    next >
PHP Script  |  2010-05-19  |  22KB  |  531 lines

  1. <?php
  2. /**
  3.  * User Interface Users tab
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   NA
  14.  * @package    NA
  15.  * @author     Nicolas Bruley / Peer 2 World <contact@weezo.net>
  16.  * @copyright  2005-2009 Nicolas Bruley / Peer 2 World
  17.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  18.  * @version    CVS: $Id:$
  19.  * @link       http://www.weezo.net
  20.  * @since      File available since Release 2.0.0
  21.  */
  22.  
  23. /**
  24.  * @desc Display user left control
  25.  *
  26.  * @param WUserConfig $user
  27.  * @param boolean $sel: true if selected
  28.  */
  29. function uiUsersControl($user,$sel){
  30.     $id=$user->id();
  31.     // Icon
  32.     $o='<div class="adminUserIcon" style="float:left"><img alt="icon" src="/gfx/icons/'.$user->getVar('icon').'" id="uiUserBlockIcon'.$id.'" style="height:55;width:55;visibility:hidden" onload="fade(this)"></div>';
  33.     // Name
  34.     $o.='<div class="uiUserBlockName" id="uiUserBlockName'.$id.'">'.str_replace('<','<',cfUTF8Encode($user->getVar('name'))).'</div>';
  35.     //Admin
  36.     if($user->isAdministrator()) $o.='<div class="uiUserBlockAdmin">'.cfCaption('userAdministrator').'</div>';
  37.     // Up
  38.     $o.=outImage(outIcon('up'),"javascript:uiUserBlockUp('".$id."')",'id="up_'.$id.'"','position:absolute;top:5px;right:5px');
  39.     // Down
  40.     $o.=outImage(outIcon('down'),"javascript:uiUserBlockDown('".$id."')",'id="down_'.$id.'"','position:absolute;top:15px;right:5px');
  41.     // Delete
  42.     if(!$user->isAdministrator()) $o.=outImage(outIcon('del'),false,'id="del_'.$id.'" onclick="uiUserDelete(\''.$id.'\')" '.outToolTip('javascript:uiUsersDeleteTooltip'),'position:absolute;bottom:5px;cursor:pointer;left:70px;'.(($sel)?'':'display:none'));
  43.     // Activate(d)
  44.     $o.='<div style="position:absolute;right:5px;bottom:5px">'.cfCaption('genActivated').'<input type="checkbox" '.(($user->getVar('activated'))?'checked="checked"':'').' onclick="uiUserActivated(\''.$id.'\')" id="activated_'.$id.'" style="vertical-align:middle"></div>';
  45.  
  46.     return outBlockItem('uiUsersRes',$o,'id="userBlock_'.$id.'" onmouseup="uiUserSelect(\''.$id.'\')"','position:absolute;padding-bottom:5px;width:200px;display:block;overflow:hidden;text-overflow:ellipsis;margin:0;margin-bottom:3px;text-align:left',false,(($sel)?'sel':'unsel'));
  47. }
  48.  
  49. /**
  50.  * @desc Return HTML code for given user configuration page
  51.  *
  52.  * @param WUserConfig $user
  53.  * @return string
  54.  */
  55. function uiUsersUserConfig($uc){
  56.     $o='';
  57.  
  58.     require_once(INCLUDE_DIR.'resourceConfigFunctions.php');
  59.     
  60.     // Send invitation button
  61.     $o.=outButton75(outImage(outIcon('mailOut')),"uiUserSendInvitation('".$uc->id()."')",'style="float:right"',cfCaption('userInvite'));
  62.  
  63.     /**
  64.      * 1st block: name, groupType, hidden, icon
  65.      */
  66.     $o.='<table class="uiUsersGroup" style="width:468px"><tr>';
  67.     // Group picture
  68.     $o.='<td style="width:48px;text-align:center"><img src="'.outIcon('uiUsersGroup').'"></td>';
  69.  
  70.     $o.='<td style="width:180px">';
  71.     // Name
  72.     $o.='<div class="title" style="margin-bottom:0.5em">'.cfCaption('genName').'</div>';
  73.     $o.='<input class="textInput uiUsersNameInput" value="'.str_replace('"','"',cfUTF8Encode($uc->getVar('name'))).'" onkeyup="uiUsersDataNameChanged(this)" onchange="uiUsersDataNameChanged(this)" id="uiUsersDataName"><br>';
  74.  
  75.     $o.='</td><td style="vertical-align:middle">';
  76.     // Group type
  77.     $o.='<select '.outToolTip(cfCaption('groupTypeDesc')).' class="textInput" type="select" onchange="uiUserUpdate(\'accountType\',this.value)">';
  78.     $o.='<option value="singleUser"'.(($uc->getVar('accountType')=='singleUser')?' selected':'').'>'.cfCaption('userAccountTypeSingleUser').'</option>';
  79.     $o.='<option value="named"'.(($uc->getVar('accountType')=='named')?' selected':'').'>'.cfCaption('userAccountTypeNamed').'</option>';
  80.     $o.='<option value="anonymous"'.(($uc->getVar('accountType')=='anonymous')?' selected':'').'>'.cfCaption('userAccountTypeAnonymous').'</option>';
  81.     $o.='</select><br><br>';
  82.  
  83.     // Hidden group
  84.     $o.='<div '.outToolTip(cfCaption('hiddenGroupDesc')).'><input type="checkbox" '.(($uc->getVar('hidden'))?'checked="checked"':'').' style="vertical-align:middle;margin-right:0.5em" onclick="uiUserUpdate(\'hidden\',this.checked)">'.cfCaption('userHidden').'</div>';
  85.  
  86.     // Icon
  87.     $o.='</td><td style="width:69px;text-align:right">';
  88.     $o.='<div class="uiUsersIcon"><img src="/gfx/icons/'.$uc->getVar('icon').'" onclick="uiUserChangeIcon()" id="selUserIcon" style="width:60px;height:60px"></div>';
  89.     $o.='</td></tr></table>';
  90.  
  91.     /**
  92.      * User not activated warning
  93.      */
  94.     $o.='<div id="uiUsersActWarning" class="extendedWarning"'.(($uc->getVar('activated'))?' style="display:none"':'').'>'.outImageIcon('warning').cfCaption('accountNotActivated').'</div>';
  95.  
  96.  
  97.     /**
  98.      * 2nd block: Password / security
  99.      */
  100.     $o.='<table class="uiUsersGroup frame2"><tr>';
  101.     // Lock picture
  102.     $o.='<td style="width:48px;text-align:center;vertical-align:top"><img src="'.outIcon('uiUsersLock').'" style="margin-top:16px"></td>';
  103.  
  104.     $o.='<td style="white-space:nowrap;position:relative">';
  105.     // Authentication method
  106.     $o.='<b>'.cfCaption('userAuthentification').'</b><br>';
  107.     $o.='<select name="passwordSelect" class="textInput" type="select" onchange="uiUsersDataAuthenticationChanged(this.value)" style="width:140px;margin-right:0.5em;vertical-align:middle">';
  108.     $o.='<option value="password"'.(($uc->getVar('authenticationMethod')=='password')?' selected':'').' id="uiUsersDataAuthenticationNA">'.cfCaption('genPassword').'</option>';
  109.     if(!$uc->isAdministrator())
  110.         $o.='<option value="noAuthentication"'.(($uc->getVar('authenticationMethod')=='noAuthentication')?' selected':'').'>'.cfCaption('userAuthenticationNoAuthentication').'</option>';
  111.     $o.='</select>';
  112.     // Password
  113.     $o.=outBt(cfCaption('genPassword'),outIcon('pwdS'),'javascript:uiUsersPwdSet()','uiUsersPwdBt',false,'style="margin-right:1em;vertical-align:middle"','up',90);
  114.  
  115.     // Hint
  116.     $o.='<span style="vertical-align:middle" '.outToolTip(str_replace('"','"',cfCaption('logHintHelp'))).'>'.cfCaption('logHint');
  117.     $o.='<input id="uiUsersDataHint" class="textInput" value="'.str_replace('"','"',cfUTF8Encode($uc->getVar('hint'))).'" onkeyup="uiUsersDataHintChanged(this)" onchange="uiUsersDataHintChanged(this)"'.(($uc->getVar('authenticationMethod')=='noAuthentication')?' disabled':'').' style="width:120px;vertical-align:middle;margin-left:0.5em">';
  118.     $o.='</span>';
  119.     $o.='<br><br> ';
  120.  
  121.     /**
  122.      * Advanced security config
  123.      */
  124.     $showAdvancedConfig=cfGGetVar('uiUsersAdvancedConfig');
  125.     // Advanced config toggle
  126.     $o.='<div class="advancedConfigToggleBt" id="advancedConfigUnfoldBt" onclick="uiUsersToggleAdvancedConfig()" style="bottom:0px;top:auto">';
  127.     $o.=cfCaption('configAdvanced');
  128.     $o.=outimage(outIcon('advancedConfigUnfold'),false,'id="advancedConfigUnfoldIco"','vertical-align:middle;'.(($showAdvancedConfig)?'':'display:none'));
  129.     $o.=outimage(outIcon('advancedConfigFold'),false,'id="advancedConfigFoldIco"','vertical-align:middle;'.((!$showAdvancedConfig)?'':'display:none'));
  130.     $o.='</div>';
  131.  
  132.     $o.='<div id="advancedConfigDiv" '.(($showAdvancedConfig)?'':'style="display:none"').'>';
  133.  
  134.     // IP restrictions
  135.     $IPIcon=($uc->getVar('IPFilter') && $uc->getVar('IPFilter')!=='no')?outIcon('warning'):outIcon('ahead');
  136.     $o.=outBt(cfCaption('configIPFilter'),$IPIcon,'javascript:uiUsersIPSet()','uiUsersIPBt',false,'style="margin-right:1em;vertical-align:middle"','up',90);
  137.  
  138.     // Max users
  139.     $o.='<span style="vertical-align:middle;margin-right:0.5em">'.cfCaption('loginMaxUsers').'</span>';
  140.     $o.='<select class="textInput" type="select" onchange="uiUserUpdate(\'maxSimultaneousUsers\',this.value)" style="margin-right:0.5em;vertical-align:middle;width:60px">';
  141.     for($i=0;$i<11;$i++){
  142.         if($i==1 || $uc->getVar('accountType')!='singleUser')
  143.         $o.='<option value="'.(int)$i.'" '.(($i==$uc->getVar('maxSimultaneousUsers'))?'selected':'').'>'.(($i)?$i:cfCaption('genUnlimited')).'</option>';
  144.     }
  145.     $o.='</select>';
  146.  
  147.     // Max download
  148.     $o.='<span style="vertical-align:middle;margin-right:0.5em;margin-left:3em">'.cfCaption('explorerDlLimit').'</span>';
  149.     $o.='<input class="textInput" value="'.(int)($uc->getVar('downloadSpeedLimit')).'" onkeyup="uiUsersDataDLLimitChanged(this)" onchange="uiUsersDataDLLimitChanged(this)" style="width:30px;vertical-align:middle;text-align:right">';
  150.     $o.='<span style="vertical-align:middle;margin-left:0.5em">'.cfCaption('explorerKBPS').'</span>';
  151.  
  152.     $o.='<br><br> </div>';
  153.  
  154.     $o.='</td></tr></table>';
  155.  
  156.  
  157.  
  158.  
  159.     /**
  160.      * 3rd block: theme, sound
  161.      */
  162.     $o.='<table class="uiUsersGroup"><tr>';
  163.     // Theme picture
  164.     $o.='<td style="width:48px;text-align:center;vertical-align:middle">'.outImage(outIcon('theme24')).'</td>';
  165.  
  166.     $o.='<td style="padding-top:5px;padding-bottom:5px">';
  167.     // Theme selection button
  168.     $o.='<span style="margin-right:2em;vertical-align:middle">'.cfCaption('configDefaultTheme').'</span>';
  169.     $o.=outButton(cfCaption('genTheme').' ('.(($uc->getVar('theme'))?ucfirst(cfUTF8Encode($uc->getVar('theme'))):cfCaption('genDefault')).')','javascript:uiUsersSelectTheme()',outIcon('theme'),false,'uiUsersSelectThemeBt','style="vertical-align:middle"');
  170.  
  171.     // Audio profile
  172.     $o.='<span style="margin-left:2em;margin-right:0.5em">'.cfCaption('userAudioProfile').'</span>';
  173.     $o.='<select class="textInput" type="select" onchange="uiUserUpdate(\'audioProfile\',this.value)" style="vertical-align:middle">';
  174.     $o.='<option value="noSound"'.(($uc->getVar('audioProfile')=='no')?' selected':'').'>'.cfCaption('userAudioNoSound').'</option>';
  175.     foreach (cfGlob(cfAppDocRoot().'/snd/*') as $cfn) if(is_dir($cfn)){
  176.  
  177.         $o.='<option value="'.basename($cfn).'"'.(($uc->getVar('audioProfile')==basename($cfn))?' selected':'').'>'.cfUTF8Encode(basename($cfn)).'</option>';
  178.     }
  179.     $o.='</select>';
  180.  
  181.  
  182.     $o.='</td></tr></table>';
  183.  
  184.     /**
  185.      * 4th block: sticky notes
  186.      */
  187.     $o.='<table class="uiUsersGroup frame2"><tr>';
  188.     // Sticky notes picture
  189.     $o.='<td style="width:48px;text-align:center"><img src="'.outIcon('sNotes24').'"></td>';
  190.  
  191.     $o.='<td style="padding-top:5px;padding-bottom:5px">';
  192.     $o.='<b style="margin-right:2em;vertical-align:middle">'.cfCaption('sNotes').'</b>';
  193.  
  194.     // Sticy notes access
  195.     $o.='<select class="textInput" type="select" onchange="uiUserUpdate(\'sNotes\',this.value)" style="vertical-align:middle">';
  196.     $o.='<option value="0"'.(($uc->getVar('sNotes')==0)?' selected':'').'>'.cfCaption('genNo').'</option>';
  197.     $o.='<option value="1"'.(($uc->getVar('sNotes')==1)?' selected':'').'>'.cfCaption('genShow').'</option>';
  198.     $o.='<option value="2"'.(($uc->getVar('sNotes')==2)?' selected':'').'>'.cfCaption('genShow').' / '.cfCaption('adminResourceCreate').'</option>';
  199.     $o.='<option value="3"'.(($uc->getVar('sNotes')==3)?' selected':'').'>'.cfCaption('genShow').' / '.cfCaption('adminResourceCreate').' / '.cfCaption('genDelete').'</option>';
  200.     $o.='</select><br>';
  201.  
  202.     $o.='</td></tr></table>';
  203.  
  204.     /**
  205.      * 5th block: bound resources
  206.      */
  207.     $o.='<table class="uiUsersGroup uiUsersResGroup" id="linkedResourcesFrame"><tr style="height:32px">';
  208.     // Resources picture
  209.     $o.='<td style="width:48px;text-align:center;vertical-align:top"><img src="'.outIcon('resources24').'"></td>';
  210.     $o.='<td style="white-space:nowrap;position:relative;vertical-align:top">';
  211.  
  212.     // Add resource button
  213.     $o.='<div style="float:right">'.outButton(cfCaption('genAdd'),'javascript:uiUsersAddResource()',outIcon('add2')).'</div>';
  214.     // User's resources title
  215.     $o.='<div class="title">'.cfCaption('userResources').'</div>';
  216.  
  217.     // Overflow node
  218.     $o.='</td></tr><tr><td colspan="2" style="vertical-align:top;position:relative"><div style="overflow:auto;height:95%" id="linkedResourcesScroll">';
  219.  
  220.  
  221.     // Bound resources
  222.     if($uc->getResources())
  223.         foreach ($uc->getResources() as $rid=>$filename) $o.=rcResourceBlock($rid,$uc);
  224.     else
  225.         $o.='<center><div style="position:relative;top:10%;width:240px;margin-left:auto;margin-right:auto"><div class="frame3" style="padding:10px">'.outImage(outIcon('info32'),false,false,'margin-bottom:5px').'<br>'.cfCaption('genNoDefinedResource').'</div></div></center>';
  226.  
  227.     $o.='</div>';
  228.     if(cfBGetVar('png')) $o.='<div class="uiUsersResMask"></div><div class="uiUsersResMask bottom"></div>';
  229.     $o.='</td></tr></table>';
  230.     return $o;
  231. }
  232.  
  233.  
  234.  
  235.  
  236. if(!cfIsInApp()) die();
  237.  
  238. require_once(INCLUDE_DIR.'outputFunctions.php');
  239.  
  240. // Get users
  241. $users=cfUsersConfigs();
  242.  
  243. /**
  244.  ***************************************************************************************************************************
  245.  * Process Async command
  246.  ***************************************************************************************************************************
  247.  */
  248. if(cfIsAsync()){
  249.     cfAsyncHeader();
  250.  
  251.     // Change users order
  252.     if(isset($_POST['userOrder'])){
  253.         $no=array();
  254.         foreach (explode(',',$_POST['userOrder']) as $uid) if(isset($users[$uid])) $no[]=$users[$uid]->filename();
  255.         cfGUpdateVar('users',implode(',',$no));
  256.     }
  257.     // Change advanced config display
  258.     if(isset($_POST['userShowAdvancedConfig'])){
  259.         cfGUpdateVar('uiUsersAdvancedConfig',(int)$_POST['userShowAdvancedConfig']);
  260.     }
  261.  
  262.     /**
  263.      * Create user
  264.      */
  265.     if(isset($_POST['userCreate'])){
  266.         $name=cfUTF8Decode($_POST['userCreate'],true,false,false);
  267.         $pwd='';
  268.         if(strpos($name,'*weezoSep*')) list($name,$pwd)=explode('*weezoSep*',$name);
  269.         $uc=new WUserConfig();
  270.         $uc->setVar('name',$name);
  271.         if($pwd){
  272.             $uc->setVar('authenticationMethod','password');
  273.             $uc->setVar('password',md5($pwd));
  274.         }
  275.         else{
  276.             $uc->setVar('authenticationMethod','noAuthentication');
  277.         }
  278.         // Pick a random icon
  279.         $icons=cfGlob(cfAppDocRoot().'/gfx/icons/*.jpg');
  280.         $uc->setVar('icon',basename($icons[rand(0,count($icons))]));
  281.  
  282.  
  283.         // Save user
  284.         $uc->save();
  285.  
  286.         // Select created user
  287.         cfGUpdateVar('uiUsersSelectedId',$uc->id());
  288.  
  289.         // Add new user block
  290.         echo cfAsyncXMLInnerHTMLbyId(uiUsersControl($uc,true),'uiUsersBlocksDiv',true);
  291.         // Select user
  292.         echo cfAsyncXMLJSaction('users[users.length]="'.$uc->id().'";uiUserResetBlocks();uiUserScrollTo("'.$uc->id().'");uiUserSelect("'.$uc->id().'");');
  293.  
  294.         // Reload page
  295.         echo cfAsyncXMLJSaction('wl.goURL()');
  296.     }
  297.  
  298.     /**
  299.      * Delete user
  300.      */
  301.     if(isset($_POST['userDelete']) && isset($users[$_POST['userDelete']])){
  302.         $uc=$users[$_POST['userDelete']];
  303.         $uc->del();
  304.         echo cfAsyncXMLJSaction('wl.goURL()');
  305.     }
  306.  
  307.     // Verify passed user id exists, or terminate requests with no specific user Id
  308.     if(!isset($_POST['userId']) || !isset($users[$_POST['userId']])) die(cfAsyncFooter());
  309.     $uc=$users[$_POST['userId']];
  310.  
  311.     // Select an user
  312.     if(isset($_POST['userSelect'])){
  313.         cfGUpdateVar('uiUsersSelectedId',$_POST['userId']);
  314.         $refreshUserConfig=true;
  315.         echo cfAsyncXMLJSaction('uiUserFile="'.$uc->filename().'"');
  316.     }
  317.     // Remove a resource from an user
  318.     if(isset($_POST['removeResource'])){
  319.         $uc->removeResource($_POST['removeResource']);
  320.         $uc->save();
  321.         $refreshUserConfig=true;
  322.     }
  323.     // Reorder user's resources
  324.     if(isset($_POST['userResMoveUp']) && isset($_POST['userResMoveDown'])){
  325.         $prev=$uc->swapResources($_POST['userResMoveUp'],$_POST['userResMoveDown']);
  326.         $uc->save();
  327.         $refreshUserConfig=true;
  328.     }
  329.     // Add resource(s)
  330.     if(isset($_POST['userAddResources'])){
  331.         foreach (explode('/',$_POST['userAddResources']) as $rid) $uc->addResource($rid);
  332.         $uc->save();
  333.         $refreshUserConfig=true;
  334.     }
  335.  
  336.     // Create new resource
  337.     if(isset($_POST['userCreateNewResource'])){
  338.         cfServerSendCmd('createNewResource');
  339.     }
  340.  
  341.  
  342.     /**
  343.      * User config modification
  344.      */
  345.     if(isset($_POST['updateData']) && isset($_POST['updateValue']) && isset($_POST['userId']) && isset($uc)){
  346.         $ok=0;
  347.         $k=$_POST['updateData'];
  348.         $v=$_POST['updateValue'];
  349.         switch ($k){
  350.             case 'name':
  351.                 $v=cfUTF8Decode($v,true,false,false,30);
  352.                 $ok=1;
  353.                 break;
  354.             case 'icon':
  355.                 if(file_exists(cfAppDocRoot().'/gfx/icons/'.$v)) $ok=1;
  356.                 break;
  357.             case 'accountType':
  358.                 if($v=='singleUser' || $v=='named' || $v=='anonymous') {
  359.                     $ok=1;
  360.                     if($v=='singleUser') $uc->setVar('maxSimultaneousUsers',1);
  361.                     elseif ($uc->getVar('maxSimultaneousUsers')==1) $uc->setVar('maxSimultaneousUsers',0);
  362.                     $refreshUserConfig=1;
  363.                 }
  364.                 break;
  365.             case 'hidden':
  366.             case 'activated':
  367.                 $v=($v=='true')?true:false;
  368.                 $ok=1;
  369.                 break;
  370.             case 'authenticationMethod':
  371.                 if($v=='noAuthentication' && !$uc->isAdministrator()) $ok=1;
  372.                 break;
  373.             case 'password':
  374.                 $v=md5(cfUTF8Decode($v,true,false,false));
  375.                 $uc->setVar('authenticationMethod','password');
  376.                 $ok=1;
  377.                 break;
  378.             case 'hint':
  379.                 $v=cfUTF8Decode($v,true,false,false,260);
  380.                 $ok=1;
  381.                 break;
  382.             case 'maxSimultaneousUsers':
  383.                 $v=(int)$v;
  384.                 if($v>=0 && $v<11)    $ok=1;
  385.                 break;
  386.             case 'downloadSpeedLimit':
  387.                 $v=(int)$v;
  388.                 if($v>=0) $ok=1;
  389.                 break;
  390.             case 'audioProfile':
  391.                 if($v=="no" || is_dir(cfAppDocRoot().'/snd/'.str_replace('/','',$v))) $ok=1;
  392.                 if($ok && $v!='no') cfServerSendCmd('userModifiedAudioProfile',array('newProfile'=>$v));
  393.                 break;
  394.             case 'sNotes':
  395.                 $v=(int)$v;
  396.                 if($v>=0 && $v<4) $ok=1;
  397.                 break;
  398.             case 'theme':
  399.                 // option already saved by theme form => just redraw
  400.                 $refreshUserConfig=1;
  401.                 break;
  402.             case 'displayResourceAtLogin':
  403.                 $ok=1;
  404.                 $refreshUserConfig=1;
  405.                 break;
  406.  
  407.         }
  408.         if($ok){
  409.             $uc->setVar($k,$v);
  410.             $uc->save();
  411.         }
  412.     }
  413.     
  414.     
  415.     if(isset($_POST['userSendInvitation']) && isset($_POST['userId'])){
  416.         //cfDbg($_POST['userId']);
  417.         $regInfo=cfIsRegistered();
  418.         
  419.         // If user is registered, call mail application
  420.         if(isset($regInfo['regName'])){
  421.             $subject=str_replace('"',"''",APPLICATION_NAME.' - '.$uc->getVar('name'));
  422.             $body=cfCaption('genAdress',DNS_SITE.'/'.$regInfo['regName'].'?user='.$uc->getVar('name'));
  423.             $body.=' , '.cfCaption('genGroup').cfCaption('genSeparator').$uc->getVar('name');
  424.             if($uc->getVar('authenticationMethod')=='password') $body.=' , '.cfCaption('genPassword').cfCaption('genSeparator').'XXXX';
  425.             $body=str_replace('"',"''",$body);
  426.             cfServerSendCommand('openMail body="'.$body.'" subject="'.$subject.'"');
  427.         }
  428.         // else just display error message
  429.         else{
  430.             $msgbox='dB=new dialogBox({"text":"'.addslashes(cfCaption('registrationNeeded')).'","title":"'.cfCaption('alertWarningTitle').'","icon":"'.outIcon('info2').'","mask":1,"fade":1,"buttons":{"cancel":"'.cfCaption('genCancel').'"}});dB.show()';
  431.             echo cfAsyncJSaction($msgbox);
  432.         }
  433.     }
  434.     
  435.     if(isset($refreshUserConfig)) {
  436.         echo cfAsyncXMLJSaction('uiUsersResScrollGet()');
  437.         echo cfAsyncXMLInnerHTMLbyId(uiUsersUserConfig($uc),'userFrame');
  438.         echo cfAsyncXMLJSaction('winResized()');
  439.         echo cfAsyncXMLJSaction('uiUsersResScrollSet()');
  440.     }
  441.  
  442.     die(cfAsyncFooter());
  443. }
  444.  
  445.  
  446. /**
  447.  ***************************************************************************************************************************
  448.  * Insert page HEADER
  449.  ***************************************************************************************************************************
  450.  */
  451. cfInsertHEAD(false);
  452. echo cfScriptLink('winClient.js');
  453. ?>
  454. <style type="text/css">
  455.  
  456. </style>
  457. </head>
  458. <body style="padding:0px;margin:0px;overflow:hidden">
  459. <?php
  460. echo cfScriptLink('wz_dragdrop.js');
  461.  
  462.  
  463. /**
  464.  ***************************************************************************************************************************
  465.  * Users list frame
  466.  ***************************************************************************************************************************
  467.  */
  468. ?>
  469. <div id="usersListFrame" class="frame2 uiLeftFrame" style="float:left;width:210px">
  470. <div class="uiTabTitle"><?php echo cfCaption('genGroups');?></div>
  471. <center>
  472. <?php
  473. // New user button
  474. echo outBt('<b style="font-weight:bold">'.cfCaption('userNewUser').'</b>',outIcon('new'),"javascript:uiUserCreate()",false,false,'style="margin-left:0;margin-right:0"','up',170);
  475. ?>
  476. <div id="uiUsersBlocksDiv" style="position:relative;overflow:auto;width:221px;height:375px;margin-left:auto;margin-right:auto;margin-top:1em;text-align:left">
  477. <?php
  478. // unique ID of selected user
  479. if(isset($_GET['userSelectedId'])) cfGUpdateVar('uiUsersSelectedId',$_GET['userSelectedId']);
  480. $uiUsersSelectedId=cfGGetVar('uiUsersSelectedId');
  481. if(!isset($users[$uiUsersSelectedId])){
  482.     foreach ($users as $id=>$user){
  483.         $uiUsersSelectedId=$id;
  484.         cfGUpdateVar('uiUsersSelectedId',$id);
  485.         break;
  486.     }
  487. }
  488.  
  489.  
  490. // Display users controls
  491. foreach ($users as $id=>$user){
  492.     echo uiUsersControl($user,($id==$uiUsersSelectedId));
  493. }
  494. ?>
  495. </center>
  496. </div><?php // eo overflow frame ?>
  497. </div><?php // eo frame2 uiLeftFrame ?>
  498. <?php
  499.  
  500.  
  501. /**
  502.  ***************************************************************************************************************************
  503.  * Configured user frame
  504.  ***************************************************************************************************************************
  505.  */
  506. ?>
  507. <div id="userFrame" class="frame1" style="display:block;margin:0px;height:473px;padding:7px;margin-left:0px">
  508. <?php
  509. echo uiUsersUserConfig($users[$uiUsersSelectedId]);
  510. ?>
  511. </div>
  512.  
  513. <?php
  514. /**
  515.  * Scripts
  516.  */
  517. ?>
  518. <script type="text/javascript">
  519. var inApp="<?php echo (int)cfIsInApp(); ?>";
  520. var uiUserSelected="<?php echo $uiUsersSelectedId; ?>";
  521. var uiShowAdvancedConfig="<?php echo (int)cfGGetVar('uiUsersAdvancedConfig'); ?>";
  522. var users=[<?php $nb=0;foreach ($users as $id=>$user) echo (($nb++==0)?'':',').'"'.$id.'"'; ?>];
  523. var uiUserFile="<?php echo $users[$uiUsersSelectedId]->filename()?>";
  524. var delConfCapt="<?php echo addslashes(cfCaption('userConfirmDelete'));?>";
  525. var uiUsersDeleteTooltip="<?php echo addslashes(outImageIcon('warning').cfCaption('genDelete'));?>";
  526. </script>
  527. <?php
  528. echo cfScriptLink('uiUsers.js');
  529. echo cfDragRegisterItems('');
  530. ?>
  531. </body>